﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Battle
{
    public class LevelScript_Debug : ILevelScript
    {
        private int _level, _count = 0, _maxEnemy = 100;
        private float _time = 0, _interval = 1f, _enemySpeed = 0.5f;

        public void StartLevel(int level)
        {
            _level = level;

            _count = 0;
            _time = 0;
        }
        public void OnUpdate(float deltaTime)
        {
            _time += deltaTime;

            if (_time > _interval)
            {
                _time -= _interval;

                CreateEnemy();
            }
        }

        private void CreateEnemy()
        {
            _count++;

            EnemyFactory.CreateNormalEnemy(new Vector3(Random.Range(-1f, 1f)*GameMgr.ScreenSize.x, GameMgr.ScreenSize.y),
                5 + _count, _enemySpeed * Random.Range(0.8f, 1.2f));

            if (_count > _maxEnemy)
            {
                LevelScriptMgr.NextLevel();
            }
        }

        public void StopLevel()
        {

        }
    }
}
